<template>
  <el-row type="flex" justify="center">
    <el-col :span="8">
      <el-form ref="formDateRef" label-position="top" label-width="80px" :model="messageData" :rules="messageRules">
        <el-form-item label="通知邮箱" prop="email">
          <el-input v-model="messageData.email" />
        </el-form-item>
        <el-form-item style="display: flex;justify-content:center">
          <el-button type="primary" plain @click="submitPas">确认修改</el-button>
        </el-form-item>
      </el-form>
    </el-col>
  </el-row>
</template>

<script>
import { getUserInfo } from '@/api/user'

export default {
  data() {
    return {
      userData: [],
      messageData: {
        id: '',
        email: ''
      },
      messageRules: {
        email: [
          {
            required: true, type: 'email', message: '请输入正确邮箱地址', trigger: 'blur'
          }
        ]
      }
    }
  },

  mounted() {
    this.getUserInfo()
  },
  methods: {
    async getUserInfo() {
      const res = await getUserInfo()
      this.messageData.email = res.email
      console.log(this.messageData)
    },
    submitPas() {
      this.$confirm('是否修改密码?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$refs.formDateRef.validate(async isok => {
          if (isok) {
            console.log(this.messageData)
            this.$message({
              type: 'success',
              message: '修改成功!'
            })
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消修改'
        })
      })
    }

  }
}
</script>

<style>

</style>
